package com.chulianyuang.controller;

import com.chulianyuang.pojo.Employee;
import com.chulianyuang.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class UserController {
    @Autowired
    private EmployeeService employeeService;

    @RequestMapping("login") //设置业务请求路径
    //@RequestMapping(name = "login",method = RequestMethod.POST)
    public String login(String sn, String password, HttpSession session){
        //public String login(@RequestParam(name = "sn") String sn,@RequestParam("password") String password){
        Employee employee = employeeService.login(sn, password);
//        System.out.println(employee);
        if(employee!=null){
            session.setAttribute("emp",employee);
            return "index";
        }else{
            return "login";
        }
    }
}
